--[[
每损失 N % 血量, 增加属性

*]]
---@class BuffEffect85 : BaseBuffEffect
BuffEffect85 = ClientFight.CreateClass("BuffEffect85", ClientFight.BaseBuffEffect)
local t = BuffEffect85
---@param fight Fight
---@param buff FighterBuff

function t:action(fight, buff, ...)
    local fighter = buff.target;
    -- 基础值
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local perConf = buffEffectValue[1];
    local hp = fighter.hp;
    local maxHp = FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.HP.id);
    hp = maxHp - hp;
    local step = hp / maxHp * 10000 / perConf;
    buff.attributes.attributes = nil;
    if (step < 1) then
        ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
        return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
    end
    for i = 2, table.getn(buffEffectValue), 2 do
        if (i + 1 >= table.getn(buffEffectValue)) then
            break ;
        end
        local attrType = buffEffectValue[i];
        local add = buffEffectValue[i + 1] * step;
        buff.attributes.attributes[attrType] =  add;
    end

    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 每损失 N % 血量, 增加属性，增加(" .. attrType .. ")" .. add);
    ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);

    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;

end

t.New()